#ifndef CUSTOMCHARTVIEW_H
#define CUSTOMCHARTVIEW_H

#include <QtCharts>
#include <QObject>
#include <QWidget>
#include <QChart>
#include <QChartView>
#include <QDebug>
#include <QLineSeries>
#include <Qtcharts/QSplineSeries>

/* 鼠标样式枚举 */
enum ArrowShape {
    Arrow = 1,
    HandPointing = 2
};

class CustomChartView : public QChartView
{
    Q_OBJECT
public:
    explicit CustomChartView(QWidget *parent = nullptr);
    ~CustomChartView() override;

signals:
    void chartViewMousePress(QMouseEvent *event); // 鼠标按下事件信号
    void chartViewMouseMove(QMouseEvent *event); // 鼠标移动事件信号
    void chartViewMouseRelease(QMouseEvent *event); // 鼠标释放事件信号
    void chartViewResize(QResizeEvent *event); // 窗口大小改变信号
    void chartViewDoubleClick(QMouseEvent *event); // 定义一个自定义信号
public:
    QMouseEvent *releaseEvent = new QMouseEvent(QEvent::MouseButtonRelease,
                                                this->rect().center(),
                                                Qt::LeftButton,
                                                Qt::LeftButton,
                                                Qt::NoModifier);
private:
    QLineSeries* famSeries;
    QChart *sChart;

    int previousCursor; // 记录上次选中的鼠标指针样式

public:
    void changeMouseArrowShape(ArrowShape arrowShape); // 改变鼠标指针样式

protected:
    void mousePressEvent(QMouseEvent *event) override; // 鼠标按下事件（重写）
    void mouseMoveEvent(QMouseEvent *event) override; // 鼠标移动事件（重写）
    void mouseReleaseEvent(QMouseEvent *event) override; // 鼠标抬起事件（重写）
    void resizeEvent(QResizeEvent *event) override; // 窗口大小改变事件（重写）
    void mouseDoubleClickEvent(QMouseEvent *event) override; // 阈值可编辑信号

};

#endif // CUSTOMCHARTVIEW_H
